---
title: "detection_period"
sidebarTitle: "detection_period"
---

```
detection_period:
  period: < time period > # supported periods: day, week, month
  count: < number of periods >
```

Configuration to define the detection period.
If the detection_period are set to 2 days, only data points in the last 2 days will be included in the detection period and could be flagged anomalous.
If detection_period is set to 7 days, the detection period will be 7 days long.

For incremental models, this is also the period for re-calculating metrics.
If metrics for buckets in the detection period were already calculated, Elementary will overwrite them. The reason behind it is to monitor recent backfills of data, if there were any.
This configuration should be changed according to your data delays.

- _Default: 2 days_
- _Relevant tests: Anomaly detection tests with `timestamp_column`_

<img src="/pics/anomalies/detection-period.png" alt="Detection Period" />

<RequestExample>

```yml test
models:
  - name: this_is_a_model
    tests:
      - elementary.volume_anomalies:
          detection_period:
            period: day
            count: 30
```

```yml model
models:
  - name: this_is_a_model
    config:
      elementary:
        detection_period:
          period: month
          count: 1
```

```yml dbt_project.yml
vars:
  detection_period:
    period: week
    count: 2
```

</RequestExample>

#### How it works?

The `detection_period` param only works for tests that have `timestamp_column` configuration.

It works differently according to the table materialization:

- **Regular tables and views** - `detection_period` defines the detection period.
- **Incremental models and sources** - `detection_period` defines the detection period, and the period for which metrics will be re-calculated.
